package com.techsen.tsweb.sys.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.techsen.tsweb.core.service.impl.BaseService;
import com.techsen.tsweb.core.util.ValidUtil;
import com.techsen.tsweb.sys.dao.DeptDao;
import com.techsen.tsweb.sys.dao.OrgDao;
import com.techsen.tsweb.sys.domain.Dept;
import com.techsen.tsweb.sys.domain.Org;
import com.techsen.tsweb.sys.service.DeptService;

@Service
public class DeptServiceImpl extends BaseService<Dept, DeptDao> implements DeptService {

    @Resource
    private OrgDao orgDao;
    
    @Resource @Override
    public void setDao(DeptDao dao) {
        this.dao = dao;
    }
    
    /**
     * 修改部门信息<br/>
     * 修改部门时，同时修改组织对象
     */
    @Override
    public void update(Dept dept) {
        if (dept != null) {
            if (ValidUtil.isValid(dept.getOrgId())) {
                Org org = dept.clone().setId(dept.getOrgId());
                this.orgDao.update(org);
            }
            super.update(dept);
        }
    }

}
